<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="下单日期" prop="createtime">
<!--        <el-date-picker clearable-->
<!--                        v-model="queryParams.createtime"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="请选择下单日期">-->
<!--        </el-date-picker>-->
        <el-date-picker
          v-model="dateRange"
          type="daterange"
          format="yyyy/MM/dd"
          value-format="yyyy/MM/dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="下单电话" prop="concatphone">
        <el-input
          v-model="queryParams.concatphone"
          placeholder="请输入下单电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="下单人" prop="concatname">
        <el-input
          v-model="queryParams.concatname"
          placeholder="请输入下单人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['system:order:add']"-->
<!--        >新增</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          :disabled="single"-->
<!--          @click="handleUpdate"-->
<!--          v-hasPermi="['system:order:edit']"-->
<!--        >修改</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['system:order:remove']"-->
<!--        >删除</el-button>-->
<!--      </el-col>-->
      <!--          v-hasPermi="['system:order:export']"-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['smy:order:export']"
        >导出</el-button>
      </el-col>
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange" border>
<!--      <el-table-column label="序号" align="center" prop="id" width="100" />-->
      <el-table-column label="下单日期" align="center" prop="createTime" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createtime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="订单类型" align="center" prop="ordertype" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.ordertype==='room'">住宿订单</span>
          <span v-if="scope.row.ordertype==='entertainment'">娱乐项目</span>
          <span v-else>餐饮订单</span>
        </template>
      </el-table-column>
      <el-table-column label="分销来源" align="center" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.distributorsource===1">商品分享</span>
          <span v-if="scope.row.distributorsource===2">微店分享</span>
          <span v-if="scope.row.distributorsource===3">商城购买</span>
          <span v-if="scope.row.distributorsource===4">凭券预约</span>
        </template>
      </el-table-column>
      <el-table-column label="商家信息" align="left" width="170">
        <template slot-scope="scope">
          <div class="info_div">
            <div>店铺名称:{{scope.row.merchantName}}</div>
            <div>联系电话:{{scope.row.merchantPhone}}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="下单人信息" align="left" width="190">
        <template slot-scope="scope">
          <div class="info_div">
            <div>下单人名称:{{scope.row.memberName}}</div>
            <div>下单人电话:{{scope.row.memberPhone}}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="买家信息" align="left" width="220">
        <template slot-scope="scope">
          <div class="info_div">
            <div>姓名:{{scope.row.concatname}}</div>
            <div>联系电话:{{scope.row.concatphone}}</div>
            <div v-if="scope.row.eattoday==='Y'" class="color_red">即点即吃</div>
            <div v-if="scope.row.diningway==='home'" class="color_red">厨师上门</div>
            <div v-if="scope.row.ordertype!=='room' && scope.row.ordertype!=='entertainment'">
              <div>预约时间:{{ parseTime(scope.row.bookingdate, '{y}-{m}-{d}') }}</div>
              <div v-if="scope.row.bookingdatetime==='12:00'">午餐</div>
              <div v-if="scope.row.bookingdatetime==='18:00'">晚餐</div>
            </div>
            <div v-if="scope.row.ordertype==='room'">
              <div>入住日期:{{ parseTime(scope.row.checkindate, '{y}-{m}-{d}') }}</div>
              <div>退房日期:{{ parseTime(scope.row.livingdate, '{y}-{m}-{d}') }}</div>
            </div>
            <div v-if="scope.row.ordertype==='entertainment'">
              <div>预约时间:{{ parseTime(scope.row.bookingdate, '{y}-{m}-{d}') }}</div>
              <div>{{scope.row.bookingdatetime}}</div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="收货信息" align="left" width="220">
        <template slot-scope="scope">
          <div class="info_div">
            <div>姓名:{{scope.row.deliveryname}}</div>
            <div>联系电话:{{scope.row.deliverymobile}}</div>
            <div>收货地址:
              <span v-if="!scope.row.deliverypca">{{scope.row.deliveryprovince}}{{scope.row.deliverycity}}{{scope.row.deliveryarea}}{{scope.row.deliveryaddress}} </span>
              <span v-if="scope.row.deliverypca">{{scope.row.deliverypca}}{{scope.row.deliveryaddress}} </span>
            </div>
          </div>
        </template>
      </el-table-column>
<!--      <el-table-column label="购买数量" align="center" prop="goodsquantity" />-->
      <el-table-column label="订单金额" align="center" prop="goodssubtotalprice" width="80" />
      <el-table-column label="支付信息" align="left" width="130">
        <template slot-scope="scope">
          <div class="info_div">
            <div>支付方式:
              <span v-if="scope.row.paymethod===1">微信</span>
              <span v-if="scope.row.paymethod===2">支付宝</span>
            </div>
            <div>支付状态:
              <span v-if="!scope.row.paystatus || scope.row.paystatus===2">未支付</span>
              <span v-if="scope.row.paystatus===1">已支付</span>
            </div>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="订单备注" align="center" prop="note" width="220" />
<!--      <el-table-column label="微信支付号" align="center" prop="payno" />-->
<!--      <el-table-column label="支付状态" align="center">-->
<!--        <template slot-scope="scope">-->
<!--          <span v-if="scope.row.paystatus===1">已支付</span>-->
<!--          <span v-if="scope.row.paystatus===2">待支付</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="订单状态" align="center" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.status===-20">已提交</span>
          <span v-if="scope.row.status===150">已接单</span>
          <span v-if="scope.row.status===100">已接单</span>
          <span v-if="scope.row.status===1000" style="font-weight: bold;color: red">已取消</span>
          <span v-if="scope.row.status===500">已完成</span>
          <div v-if="scope.row.paymethod===7 && scope.row.paystatus===1" style="font-weight: bold;color: red">已扣积分</div>
        </template>
      </el-table-column>


<!--      <el-table-column label="${comment}" align="center" prop="shippingaddress" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shippingmethod" />-->
<!--      <el-table-column label="${comment}" align="center" prop="status" />-->
<!--      <el-table-column label="${comment}" align="center" prop="memberId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="merchantId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="haveinvoice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="invoicetfn" />-->
<!--      <el-table-column label="${comment}" align="center" prop="invoicetitle" />-->
<!--      <el-table-column label="${comment}" align="center" prop="invoicetitletype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="invoicetype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="havecoupon" />-->
<!--      <el-table-column label="${comment}" align="center" prop="couponId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="marketingtype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="giftactivityId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="havashoppingcardrecord" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shoppingcardmoney" />-->
<!--      <el-table-column label="${comment}" align="center" prop="shoppingcardrecordId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="finalpaymentprice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="prepaiddepositprice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="presellretainagepayno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="presellretainagepaytime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.presellretainagepaytime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="presellsubscriptionpayno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="presellsubscriptionpaytime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.presellsubscriptionpaytime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="${comment}" align="center" prop="issupplier" />-->
<!--      <el-table-column label="${comment}" align="center" prop="blanceprice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="isblanceorder" />-->
<!--      <el-table-column label="${comment}" align="center" prop="supplierbankaccountholder" />-->
<!--      <el-table-column label="${comment}" align="center" prop="supplierbankcardno" />-->
<!--      <el-table-column label="${comment}" align="center" prop="supplierbankname" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankcardpaynote" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bankcardpayphoto" />-->
<!--      <el-table-column label="${comment}" align="center" prop="deliverytype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="isissuingtype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="supplierId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="expresscode" />-->
<!--      <el-table-column label="${comment}" align="center" prop="iscloudstoredelivery" />-->
<!--      <el-table-column label="${comment}" align="center" prop="applydistributor" />-->
<!--      <el-table-column label="${comment}" align="center" prop="distributionorder" />-->
<!--      <el-table-column label="${comment}" align="center" prop="distributorId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="distributionprice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="distributorsource" />-->
<!--      <el-table-column label="${comment}" align="center" prop="liveSessionId" />-->
<!--      <el-table-column label="${comment}" align="center" prop="apppay" />-->

<!--      <el-table-column label="${comment}" align="center" prop="ordertype" />-->
<!--      <el-table-column label="${comment}" align="center" prop="standbymobile" />-->
<!--      <el-table-column label="${comment}" align="center" prop="runnername" />-->
<!--      <el-table-column label="${comment}" align="center" prop="deliverypca" />-->
<!--      <el-table-column label="${comment}" align="center" prop="deliverylat" />-->
<!--      <el-table-column label="${comment}" align="center" prop="deliverylon" />-->
<!--      <el-table-column label="${comment}" align="center" prop="balloonfee" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bookingdate" />-->
<!--      <el-table-column label="${comment}" align="center" prop="bookingdatetime" />-->
<!--      <el-table-column label="${comment}" align="center" prop="cleanfee" />-->
<!--      <el-table-column label="${comment}" align="center" prop="deskfee" />-->
<!--      <el-table-column label="${comment}" align="center" prop="dishamount" />-->
<!--      <el-table-column label="${comment}" align="center" prop="linkorderid" />-->
<!--      <el-table-column label="${comment}" align="center" prop="needballoon" />-->
<!--      <el-table-column label="${comment}" align="center" prop="needclean" />-->
<!--      <el-table-column label="${comment}" align="center" prop="needdesk" />-->
<!--      <el-table-column label="${comment}" align="center" prop="needinvoice" />-->
<!--      <el-table-column label="${comment}" align="center" prop="serviceamount" />-->
<!--      <el-table-column label="${comment}" align="center" prop="payamount" />-->
<!--      <el-table-column label="${comment}" align="center" prop="needmaterial" />-->
<!--      <el-table-column label="${comment}" align="center" prop="diningway" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="small"
            type="text"
            icon="el-icon-view"
            @click="handleOrderDetail(scope.row)"
            v-hasPermi="['smy:order:detail']"
          >查看</el-button>
          <el-button
            size="small"
            type="text"
            icon="el-icon-check"
            @click="handleOrderAudit(scope.row,'Y')"
            v-hasPermi="['smy:order:audit']"
            v-if="scope.row.distributorsource===4 && scope.row.status===-20"
          >确认订单</el-button>
          <el-button
            size="small"
            type="text"
            icon="el-icon-close"
            @click="handleOrderAudit(scope.row,'N')"
            v-hasPermi="['smy:order:audit']"
            v-if="scope.row.distributorsource===4 && scope.row.status===-20"
          >取消订单</el-button>
          <el-button
            size="small"
            type="text"
            icon="el-icon-check"
            @click="handleSettingShopAmount(scope.row,'Y')"
            v-hasPermi="['smy:order:audit']"
            v-if="scope.row.distributorsource===4 && scope.row.status===-20"
          >设置商家金额</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">

        <el-row>
          <el-col :span="8">
            <el-form-item label="订单号">
              <span>{{form.id}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="下单时间">
              <span>{{ parseTime(form.createtime) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单类型">
              <span v-if="form.ordertype==='room'">住宿订单</span>
              <span v-else>餐饮订单</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="商家名称">
              <div>{{form.merchantName}}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单金额">
              <div>{{form.goodssubtotalprice}}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="使用方式" v-if="form.eattoday==='Y'">
              <div>即点即吃</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="商品详情" v-if="form.eattoday!=='Y'">
          <el-table show-summary border v-loading="loading" :data="form.orderDetailList" v-if="form.orderDetailList && form.orderDetailList.length>0">
            <el-table-column label="商品图片" align="center">
              <template slot-scope="scope">
                <image-preview :src="scope.row.defaultimage" :width="50" :height="50"/>
              </template>
            </el-table-column>
            <el-table-column label="商品名称" align="center" prop="goodsname" />
            <el-table-column label="商品单价" align="center" prop="unitprice" />
            <el-table-column label="购买数量" align="center" prop="quantity"/>
            <el-table-column label="小计" align="center" prop="price"/>
          </el-table>
        </el-form-item>

        <el-form-item label="商家分成" prop="shopamount">
          <el-input-number v-model="form.shopamount" :precision="2" :step="0.01" :max="form.goodssubtotalprice"></el-input-number>
        </el-form-item>

<!--        <el-form-item label="${comment}" prop="deliveryaddress">-->
<!--          <el-input v-model="form.deliveryaddress" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliveryarea">-->
<!--          <el-input v-model="form.deliveryarea" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverycity">-->
<!--          <el-input v-model="form.deliverycity" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverymobile">-->
<!--          <el-input v-model="form.deliverymobile" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliveryname">-->
<!--          <el-input v-model="form.deliveryname" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliveryprovince">-->
<!--          <el-input v-model="form.deliveryprovince" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverytime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.deliverytime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="expresscompany">-->
<!--          <el-input v-model="form.expresscompany" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="expressesno">-->
<!--          <el-input v-model="form.expressesno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="finishtime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.finishtime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="freightprice">-->
<!--          <el-input v-model="form.freightprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="goodsquantity">-->
<!--          <el-input v-model="form.goodsquantity" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="goodssubtotalprice">-->
<!--          <el-input v-model="form.goodssubtotalprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="isaftersale">-->
<!--          <el-input v-model="form.isaftersale" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="note">-->
<!--          <el-input v-model="form.note" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="orderno">-->
<!--          <el-input v-model="form.orderno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="paymethod">-->
<!--          <el-input v-model="form.paymethod" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="payno">-->
<!--          <el-input v-model="form.payno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="paytime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.paytime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="price">-->
<!--          <el-input v-model="form.price" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="receipttime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.receipttime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="shippingaddress">-->
<!--          <el-input v-model="form.shippingaddress" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="shippingmethod">-->
<!--          <el-input v-model="form.shippingmethod" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="memberId">-->
<!--          <el-input v-model="form.memberId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="merchantId">-->
<!--          <el-input v-model="form.merchantId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="haveinvoice">-->
<!--          <el-input v-model="form.haveinvoice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="invoicetfn">-->
<!--          <el-input v-model="form.invoicetfn" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="invoicetitle">-->
<!--          <el-input v-model="form.invoicetitle" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="havecoupon">-->
<!--          <el-input v-model="form.havecoupon" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="couponId">-->
<!--          <el-input v-model="form.couponId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="giftactivityId">-->
<!--          <el-input v-model="form.giftactivityId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="havashoppingcardrecord">-->
<!--          <el-input v-model="form.havashoppingcardrecord" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="shoppingcardmoney">-->
<!--          <el-input v-model="form.shoppingcardmoney" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="shoppingcardrecordId">-->
<!--          <el-input v-model="form.shoppingcardrecordId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="finalpaymentprice">-->
<!--          <el-input v-model="form.finalpaymentprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="prepaiddepositprice">-->
<!--          <el-input v-model="form.prepaiddepositprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="presellretainagepayno">-->
<!--          <el-input v-model="form.presellretainagepayno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="presellretainagepaytime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.presellretainagepaytime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="presellsubscriptionpayno">-->
<!--          <el-input v-model="form.presellsubscriptionpayno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="presellsubscriptionpaytime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.presellsubscriptionpaytime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="issupplier">-->
<!--          <el-input v-model="form.issupplier" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="blanceprice">-->
<!--          <el-input v-model="form.blanceprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="isblanceorder">-->
<!--          <el-input v-model="form.isblanceorder" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="supplierbankaccountholder">-->
<!--          <el-input v-model="form.supplierbankaccountholder" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="supplierbankcardno">-->
<!--          <el-input v-model="form.supplierbankcardno" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="supplierbankname">-->
<!--          <el-input v-model="form.supplierbankname" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="bankcardpaynote">-->
<!--          <el-input v-model="form.bankcardpaynote" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="bankcardpayphoto">-->
<!--          <el-input v-model="form.bankcardpayphoto" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="supplierId">-->
<!--          <el-input v-model="form.supplierId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="expresscode">-->
<!--          <el-input v-model="form.expresscode" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="iscloudstoredelivery">-->
<!--          <el-input v-model="form.iscloudstoredelivery" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="applydistributor">-->
<!--          <el-input v-model="form.applydistributor" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="distributionorder">-->
<!--          <el-input v-model="form.distributionorder" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="distributorId">-->
<!--          <el-input v-model="form.distributorId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="distributionprice">-->
<!--          <el-input v-model="form.distributionprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="distributorsource">-->
<!--          <el-input v-model="form.distributorsource" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="liveSessionId">-->
<!--          <el-input v-model="form.liveSessionId" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="apppay">-->
<!--          <el-input v-model="form.apppay" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="checktime">-->
<!--          <el-date-picker clearable-->
<!--                          v-model="form.checktime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="请选择${comment}">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="liveprice">-->
<!--          <el-input v-model="form.liveprice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="money">-->
<!--          <el-input v-model="form.money" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="runnerphone">-->
<!--          <el-input v-model="form.runnerphone" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="standbymobile">-->
<!--          <el-input v-model="form.standbymobile" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="runnername">-->
<!--          <el-input v-model="form.runnername" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverypca">-->
<!--          <el-input v-model="form.deliverypca" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverylat">-->
<!--          <el-input v-model="form.deliverylat" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deliverylon">-->
<!--          <el-input v-model="form.deliverylon" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="balloonfee">-->
<!--          <el-input v-model="form.balloonfee" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="bookingdate">-->
<!--          <el-input v-model="form.bookingdate" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="bookingdatetime">-->
<!--          <el-input v-model="form.bookingdatetime" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="cleanfee">-->
<!--          <el-input v-model="form.cleanfee" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="deskfee">-->
<!--          <el-input v-model="form.deskfee" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="dishamount">-->
<!--          <el-input v-model="form.dishamount" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="linkorderid">-->
<!--          <el-input v-model="form.linkorderid" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needballoon">-->
<!--          <el-input v-model="form.needballoon" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needclean">-->
<!--          <el-input v-model="form.needclean" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needdesk">-->
<!--          <el-input v-model="form.needdesk" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needinvoice">-->
<!--          <el-input v-model="form.needinvoice" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="serviceamount">-->
<!--          <el-input v-model="form.serviceamount" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="payamount">-->
<!--          <el-input v-model="form.payamount" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needmaterial">-->
<!--          <el-input v-model="form.needmaterial" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="diningway">-->
<!--          <el-input v-model="form.diningway" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="concatname">-->
<!--          <el-input v-model="form.concatname" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="concatphone">-->
<!--          <el-input v-model="form.concatphone" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="needroom">-->
<!--          <el-input v-model="form.needroom" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->

<!--        <el-form-item label="${comment}" prop="checkindate">-->
<!--          <el-input v-model="form.checkindate" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="livingdate">-->
<!--          <el-input v-model="form.livingdate" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="couponnum">-->
<!--          <el-input v-model="form.couponnum" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="${comment}" prop="eattoday">-->
<!--          <el-input v-model="form.eattoday" placeholder="请输入${comment}" />-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleAudit">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
.color_red{
  font-weight: bold;
  color: red;
}

</style>

<script>
import {listOrder, getOrder, delOrder, addOrder, updateOrder, auditOrder, getOrderDetail,auditAndSend} from "@/api/smy/mallOrder";

export default {
  name: "Order",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRange:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        autocanceltime: null,
        cancelnote: null,
        canceltime: null,
        createtime: null,
        deliveryaddress: null,
        deliveryarea: null,
        deliverycity: null,
        deliverymobile: null,
        deliveryname: null,
        deliveryprovince: null,
        deliverytime: null,
        expresscompany: null,
        expressstatus: null,
        expressesno: null,
        finishtime: null,
        freightprice: null,
        goodsquantity: null,
        goodssubtotalprice: null,
        isaftersale: null,
        note: null,
        orderno: null,
        paymethod: null,
        payno: null,
        paystatus: null,
        paytime: null,
        price: null,
        receipttime: null,
        shippingaddress: null,
        shippingmethod: null,
        status: null,
        memberId: null,
        merchantId: null,
        haveinvoice: null,
        invoicetfn: null,
        invoicetitle: null,
        invoicetitletype: null,
        invoicetype: null,
        havecoupon: null,
        couponId: null,
        marketingtype: null,
        giftactivityId: null,
        havashoppingcardrecord: null,
        shoppingcardmoney: null,
        shoppingcardrecordId: null,
        finalpaymentprice: null,
        prepaiddepositprice: null,
        presellretainagepayno: null,
        presellretainagepaytime: null,
        presellsubscriptionpayno: null,
        presellsubscriptionpaytime: null,
        issupplier: null,
        blanceprice: null,
        isblanceorder: null,
        supplierbankaccountholder: null,
        supplierbankcardno: null,
        supplierbankname: null,
        bankcardpaynote: null,
        bankcardpayphoto: null,
        deliverytype: null,
        isissuingtype: null,
        supplierId: null,
        expresscode: null,
        iscloudstoredelivery: null,
        applydistributor: null,
        distributionorder: null,
        distributorId: null,
        distributionprice: null,
        distributorsource: null,
        liveSessionId: null,
        apppay: null,
        checktime: null,
        liveprice: null,
        money: null,
        runnerphone: null,
        ordertype: null,
        standbymobile: null,
        runnername: null,
        deliverypca: null,
        deliverylat: null,
        deliverylon: null,
        balloonfee: null,
        bookingdate: null,
        bookingdatetime: null,
        cleanfee: null,
        deskfee: null,
        dishamount: null,
        linkorderid: null,
        needballoon: null,
        needclean: null,
        needdesk: null,
        needinvoice: null,
        serviceamount: null,
        payamount: null,
        needmaterial: null,
        diningway: null,
        concatname: null,
        concatphone: null,
        needroom: null,
        shopamount: null,
        checkindate: null,
        livingdate: null,
        couponnum: null,
        eattoday: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        expressstatus: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        freightprice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        goodsquantity: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        goodssubtotalprice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isaftersale: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        paymethod: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        paystatus: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        price: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        shippingmethod: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        status: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        haveinvoice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        invoicetitletype: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        invoicetype: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        havecoupon: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        marketingtype: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        havashoppingcardrecord: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        shoppingcardmoney: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        finalpaymentprice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        prepaiddepositprice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        issupplier: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        blanceprice: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isblanceorder: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        deliverytype: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        isissuingtype: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        iscloudstoredelivery: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        apppay: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        money: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        balloonfee: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        cleanfee: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        deskfee: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        dishamount: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        serviceamount: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        payamount: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        shopamount: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        autocanceltime: null,
        cancelnote: null,
        canceltime: null,
        createtime: null,
        deliveryaddress: null,
        deliveryarea: null,
        deliverycity: null,
        deliverymobile: null,
        deliveryname: null,
        deliveryprovince: null,
        deliverytime: null,
        expresscompany: null,
        expressstatus: 0,
        expressesno: null,
        finishtime: null,
        freightprice: null,
        goodsquantity: null,
        goodssubtotalprice: null,
        isaftersale: null,
        note: null,
        orderno: null,
        paymethod: null,
        payno: null,
        paystatus: 0,
        paytime: null,
        price: null,
        receipttime: null,
        shippingaddress: null,
        shippingmethod: null,
        status: 0,
        memberId: null,
        merchantId: null,
        haveinvoice: null,
        invoicetfn: null,
        invoicetitle: null,
        invoicetitletype: null,
        invoicetype: null,
        havecoupon: null,
        couponId: null,
        marketingtype: null,
        giftactivityId: null,
        havashoppingcardrecord: null,
        shoppingcardmoney: null,
        shoppingcardrecordId: null,
        finalpaymentprice: null,
        prepaiddepositprice: null,
        presellretainagepayno: null,
        presellretainagepaytime: null,
        presellsubscriptionpayno: null,
        presellsubscriptionpaytime: null,
        issupplier: null,
        blanceprice: null,
        isblanceorder: null,
        supplierbankaccountholder: null,
        supplierbankcardno: null,
        supplierbankname: null,
        bankcardpaynote: null,
        bankcardpayphoto: null,
        deliverytype: null,
        isissuingtype: null,
        supplierId: null,
        expresscode: null,
        iscloudstoredelivery: null,
        applydistributor: null,
        distributionorder: null,
        distributorId: null,
        distributionprice: null,
        distributorsource: null,
        liveSessionId: null,
        apppay: null,
        checktime: null,
        liveprice: null,
        money: null,
        runnerphone: null,
        ordertype: null,
        standbymobile: null,
        runnername: null,
        deliverypca: null,
        deliverylat: null,
        deliverylon: null,
        balloonfee: null,
        bookingdate: null,
        bookingdatetime: null,
        cleanfee: null,
        deskfee: null,
        dishamount: null,
        linkorderid: null,
        needballoon: null,
        needclean: null,
        needdesk: null,
        needinvoice: null,
        serviceamount: null,
        payamount: null,
        needmaterial: null,
        diningway: null,
        concatname: null,
        concatphone: null,
        needroom: null,
        shopamount: null,
        checkindate: null,
        livingdate: null,
        couponnum: null,
        eattoday: null
      };
      this.dateRange =[];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if(this.dateRange.length>1){
        this.queryParams.startDate = this.dateRange[0];
        this.queryParams.endDate = this.dateRange[1];
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange =[];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getOrder(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改【请填写功能名称】";
      });
    },
    handleSettingShopAmount(row,optType){
      this.reset();
      const id = row.id;
      getOrderDetail(id).then(response=>{
        this.form = response.data;
        this.open = true;
        this.title = "确认订单";
      });
    },
    //确认订单
    handleAudit(){
      this.$refs["form"].validate(valid => {
        if (valid) {
          auditAndSend(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
        }
      });
    },
    handleOrderAudit(row,optType){
      let optDto={
        optId:row.id,
        optType
      }
      let message = "是否";
      if(optType==='Y'){
        message+='确认序号为"'+row.id+'"的订单？';
      }
      if(optType==='N'){
        message+='取消序号为"'+row.id+'"的订单？';
      }
      this.$modal.confirm(message).then(function() {
        return auditOrder(optDto);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    //跳转到订单详情页
    handleOrderDetail(row){
      this.$router.push("/mallOrder/orderDetail?orderId="+row.id);
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function() {
        return delOrder(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('smy/mallOrder/export', {
        ...this.queryParams
      }, `订单导出_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
